package com.ruoyi.assets.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 资产对象 state_asset
 * 
 * @author ruoyi
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("state_asset")
public class StateAsset extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @TableId(type = IdType.AUTO)
    private Long id;

    /** 资产名称 */
    @Excel(name = "资产名称")
    private String name;

    /** 类型 */
    @Excel(name = "类型", dictType = "asset_type")
    private Integer type;

    /** 面积 */
    @Excel(name = "面积")
    private String area;

    /** 租赁期限 */
    @Excel(name = "租赁期限")
    private String leaseTerm;

    /** 联系人 */
    @Excel(name = "联系人")
    private String contactUnit;

    /** 联系方式 */
    @Excel(name = "联系方式")
    private String contactInformation;

    /** 详细地址 */
    @Excel(name = "详细地址")
    private String address;

    /** 街道名称 */
    @Excel(name = "街道名称")
    private String streetName;

    /** 所属单位 */
    @Excel(name = "所属单位")
    private String ownerUnit;

    /** 用途类型 */
    @Excel(name = "用途类型")
    private String usageType;

    /** 评估时间 */
    @Excel(name = "评估时间")
    private String evaluationTime;

    /** 土地性质 */
    @Excel(name = "土地性质")
    private String landNature;

    /** 装修 */
    @Excel(name = "装修")
    private String decoration;

    /** 所在楼层 */
    @Excel(name = "所在楼层")
    private String floor;

    /** 层高 */
    @Excel(name = "层高")
    private String floorHeight;

    /** 楼栋 */
    @Excel(name = "楼栋")
    private String building;

    /** 单元 */
    @Excel(name = "单元")
    private String unit;

    /** 房号 */
    @Excel(name = "房号")
    private String roomNumber;

    /** 盘活方式 */
    @Excel(name = "盘活方式")
    private String revitalizationMethod;

    /** 权利性质 */
    @Excel(name = "权利性质")
    private String pricePropertyNature;

    /** 建筑年代 */
    private String buildingAge;

    /** 资产状态  0 维护中，1展示中，2已出租*/
    @Excel(name = "资产状态", dictType = "asset_status")
    private Integer assetStatus;

    /** 审核状态 0 下架 1上架*/
    @Excel(name = "审核状态", readConverterExp = "0=下架,1=上架")
    private Integer auditStatus;

    /** 租金 */
    @Excel(name = "年租金")
    private String rent;

    /** 出让价格 */
    @Excel(name = "出让价格")
    private String transferPrice;

    /** 备注 */
    @Excel(name = "详情介绍")
    private String remark;

    /** 图片链接 */
    private String imageUrl;

    /**
     * 维度
     */
    @Excel(name = "维度")
    private String latitude;

    /**
     * 经度
     */
    @Excel(name = "经度")
    private String longitude;

    /** 排序字段 */
    @Excel(name = "排序")
    private Integer sorted;

    public String getRent() {
        if (StringUtils.isNotBlank(rent) && !rent.contains("元") && !rent.contains("面议")) {
            return rent + "万元/年";
        } else if (StringUtils.isNotBlank(rent) && rent.contains("万元") && !rent.contains("/年")) {
            return rent.replace("万元", "万元/年");
        }
        return rent;
    }

    public String getTransferPrice() {
        if (StringUtils.isNotBlank(transferPrice) && !transferPrice.contains("元") && !transferPrice.contains("面议")) {
            return transferPrice + "万元";
        }
        return transferPrice;
    }


    /**
     * 获取楼栋/单元/房号格式化显示
     */
    public String getBuildingInfo() {
        StringBuilder sb = new StringBuilder();
        
        // 处理楼栋
        if (StringUtils.isNotBlank(building)) {
            sb.append(building.trim());
        }
        
        // 处理单元
        if (StringUtils.isNotBlank(unit)) {
            if (sb.length() > 0) {
                sb.append("/");
            }
            sb.append(unit.trim());
        }
        
        // 处理房号
        if (StringUtils.isNotBlank(roomNumber)) {
            if (sb.length() > 0) {
                sb.append("/");
            }
            sb.append(roomNumber.trim());
        }
        
        return sb.toString();
    }

    /**
     * 获取楼栋/单元/房号的标签名称
     */
    public String getBuildingInfoLabel() {
        boolean hasBuilding = StringUtils.isNotBlank(building);
        boolean hasUnit = StringUtils.isNotBlank(unit);
        boolean hasRoomNumber = StringUtils.isNotBlank(roomNumber);
        
        if (hasBuilding && hasUnit && hasRoomNumber) {
            return "楼栋/单元/房号";
        } else if (hasBuilding && hasUnit) {
            return "楼栋/单元";
        } else if (hasBuilding && hasRoomNumber) {
            return "楼栋/房号";
        } else if (hasUnit && hasRoomNumber) {
            return "单元/房号";
        } else if (hasBuilding) {
            return "楼栋";
        } else if (hasUnit) {
            return "单元";
        } else if (hasRoomNumber) {
            return "房号";
        } else {
            return "";
        }
    }
}